﻿

<?php
//===============================
//  栏目管理/菜单管理   
//===============================

    $ClassFields=array(5);
	$MyClassDB=new YYBDB();
	$MyClassDB->TableName=$SystemTablename[0];
	$ListPropertyPageTdNum=1;//显示字段总数
	$arrlistTitleNum[]=array();
	$shangjiId=0;

//显示上面的标题
function getTitle($mydb,$MenuId)
{
	
	$mydb->TableName=reTableName($mydb,$MenuId);
	$MenuIdnum=$mydb->getMenuIdNum($MenuId);
		if($MenuId=="") return "";
		global $SystemTablename;
		global $SystemConest;
		global $ListPropertyPageTdNum;
		global $arrlistTitleNum;
		global $shangjiId;
		$k=0;
		$rsc=$mydb->db_query("Select * From ".$SystemConest[7].$SystemTablename[0]." Where  ".$SystemTablename[0]."2=".$Fid."  and ".$SystemTablename[0].$MenuIdnum."=" .$MenuId. " Order by ".$SystemTablename[0]."3");
		$StrListConfig=GetListConfig($mydb,$MenuId);
		
	if(is_null($StrListConfig)==true)
	{
		$ArrListConfig=explode(",",",,,");
	}
	else
	{
		$ArrListConfig=explode(",",$StrListConfig);
	}	
	
	$Titlefields=explode("|",$ArrListConfig[0]);
	
	$titleFieldNumArr=array();
	foreach($Titlefields as $values )
	{
		
		$temp=explode("/",$values);
		$titleFieldNumArr[]=$temp[0];
	}
	
	$rsM=$mydb->db_query("select * from ".$SystemConest[7].$SystemTablename[2]." where ".$SystemTablename[2]."0 =".$MenuId);
	if($rst=$mydb->db_fetch_array($rsM))
	{
		$Arr_configlist=explode(",",$rst[7]);
		$kk=0;
		foreach($Arr_configlist as $v)
		{
			$va2=explode("|",$v);
			if($va2[0]=="上级栏目")
				{
					$shangjiId=$kk;
					break;
				}
		$kk++;		
		}
		
		
		for($i=0;$i<count($titleFieldNumArr);$i++)
		{
			for($j=1;$j<count($Arr_configlist);$j++)
			{
				
				$FieldsC=explode("|",$Arr_configlist[$j]);
				
				if($titleFieldNumArr[$i]==$j and $FieldsC[0] !="")
				{
					$strReturn=$strReturn."<td style='color:#FFF' align='center'>".$FieldsC[0]."</td>";
					$ListPropertyPageTdNum=$ListPropertyPageTdNum+1;
					$arrlistTitleNum[$k]=$j;
					$k++;
				}
			}
			
		}
		
	}
	
	return $strReturn."<td style='color:#FFF' align='center'>操作</td>";
}



 //显示一级栏目列表
function ClassSys_ShowClass1List($mypage,$MenuId,$Fid,$lenvo,$inLenvo,$fanyenum="1000")
{	
		
		
		$mypage->TableName=reTableName($mypage,$MenuId);
		$MenuIdnum=$mypage->getMenuIdNum($MenuId);
		
		
		if($MenuId=="") return "";
		global $SystemTablename;
		global $SystemConest;
		$bsnum=0;
		$sqlstr="Select * From ".$SystemConest[7].$SystemTablename[0]." Where  ".$SystemTablename[0]."2=".$Fid."  and ".$SystemTablename[0].$MenuIdnum."=" .$MenuId. " Order by ".$SystemTablename[0]."3 ";
		if($fanyenum!="1000"){
			$mypage->pagecount=$fanyenum;
			$mypage->StrPage="p";
			$mypage->otherUrl="&MenuId=".$_REQUEST["MenuId"];//若有值请以"&"开始
			$mypage->numShowStyle=0;//显示分页样式
			$mypage->sql=$mypage->FenyeSql($sqlstr);//查询的条件
			$bsnum=$mypage->ReturnBeginNumber();//用于那个循环的sql语句的起始记录
		}
		
		$rsc=$mypage->db_query($sqlstr." limit $bsnum,".$fanyenum);
		
		
		
		$StrListConfig=GetListConfig($mypage,$MenuId);
		
	if(is_null($StrListConfig)==true)
	{
		$ArrListConfig=explode(",",",,,");
	}
	else
	{
		$ArrListConfig=explode(",",$StrListConfig);
	}	
	
    $ArrHead=explode("|",$ArrListConfig[0]);
	$FormConfig1=GetFormConfig($mypage,$MenuId);
	if(is_null($FormConfig1)==true) return "";
	$ArrFormConfig=explode(",",$FormConfig1);
	
?></p>
	
    <tr>
  <?php 
  for($i=0;$i<count($ArrHead);$i++)
  {
  		$Rs=explode("/",$ArrHead[$i]);

   ?>
   
	 <?php  if(count($Rs)>0){  ?>
	 		<?php  if(str_replace(" ","",$rs[1])<>""){ ?> width="<?php echo $Rs[1];?>"  <? }?> 
	 <?php }?>
	<? 
	 $arr=explode("|",$ArrFormConfig[$Rs[0]]);
  }
	 ?>

		<?
		if($mypage->db_num_rows($rsc)<1)
		{
			return "";
		}
		
		while($Menu1Rs=$mypage->db_fetch_array($rsc))
		{
			if($Fid!=$MaxClassID) $tt="";
			for($j=$inLenvo;$j<$lenvo;$j++)
			{
				$tt=$tt."&nbsp;&nbsp;&nbsp;&nbsp;";
			}
			?>
			  <tr <? if($lenvo==1)
			  {
			   echo "class='YKTtr'";
			   }
			   else
			   {
			   		echo " bgcolor='#ffffff'";
			   }
			   ?>  Height="25">
			<?  
			for($i=0;$i<count($ArrHead);$i++)
			{
					$Rs=explode("/",$ArrHead[$i]);
					
					if($Rs[2]=="")
					{
						$align="center" ;
					}
					else
					{
						$align=$Rs[2];
					}
			 ?>  
				<td class="YKTtd" ><div align="<? echo $align;?>">
				
				<?
				$arrspan="";
				if($Fid>1)
				{
					$arrspan="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
				}
				echo $arrspan.$tt;
				
					$FieldType_arr=explode("|",$ArrFormConfig[$Rs[0]]);
					 $FieldType=$FieldType_arr[1];
					 if($FieldType==2 || $FieldType==3)
					 {
						echo GetClassName($mypage,$Menu1Rs[(int)($Rs[0])],$Rs[0]);
					 }
					 else{ 
						if(GetInputType($FormConfig1,(int)($Rs[0]))==10){
							   if(is_null($Menu1Rs[(int)($Rs[0])])==false){
									$Arr1=explode("|",$Menu1Rs[(int)($Rs[0])]);
									$A=$Arr1[0];
									if($A=="1"){
										echo "已审核";
									}
									else{
										echo "未审核";
									}
							   }
							   else{
								   echo "未审核";
								}

							}
							else
							{
								$aa=str_replace(" ","",$Rs[0]);
								 echo $Menu1Rs[(int)($aa)];
							}
					}
				?>
				</div></td>
		<? } ?>	
				<td class="YKTtd"><div align="center">
				
				<a href="../menusys/Sys_Add.php?MenuId=<? echo $_REQUEST["MenuId"];?>&CMID=<? echo $_REQUEST["CMID"];?>&PMID=<? echo $_REQUEST["PMID"];?>&OwerID=<? echo $Menu1Rs[0];?>" class="Link12">添加下级</a> |

				<a href="../menusys/Sys_Update.php?MenuId=<? echo $_REQUEST["MenuId"];?>&CMID=<? echo $_REQUEST["CMID"];?>&PMID=<? echo $_REQUEST["PMID"];?>&OwerID=<? echo $Menu1Rs[0];?>&ID=<? echo $Menu1Rs[0];?>" class="Link12">修改</a> | <a href="../menusys/Sys_Delete.php?MenuId=<? echo $_REQUEST["MenuId"];?>&CMID=<? echo $_REQUEST["CMID"];?>&PMID=<? echo $_REQUEST["PMID"];?>&OwerID=<? echo $Menu1Rs[0];?>&ID=<? echo $Menu1Rs[0];?>" class="Link12">删除</a></div></td>
			  </tr>
			
			<?	
			ClassSys_ShowClass1List($mypage,$MenuId,$Menu1Rs[0],$lenvo+1,$inLenvo);//递归调用下级目录
				
	  }	
	  
}
	

//获取二级栏数
function ClassSys_GetClass2Num($mydb,$Menu1ID)
{
	global $SystemTablename;
	global $SystemConest;
	if($Menu1ID=="") return "";
	$rsc=$mydb->db_query("Select Count(*) From ".$SystemConest[7].$SystemTablename[0]." Where ".$SystemTablename[0]."2=".$Menu1ID);
	$MenuRs=$mydb->db_fetch_array($rsc);
	$num=$mydb->db_num_rows($rsc);
	if($num>0)
	{
		return $MenuRs[0];
	}
}	
	
	
//获取分类名称
function GetClassName($mydb,$ClassID,$dnum)
{
	if($ClassID=="") return "";
	global $SystemTablename;
	global $SystemConest;
	$sqlrs="Select ".$SystemTablename[0]."1 From ".$SystemConest[7].$SystemTablename[0]." Where ".$SystemTablename[0]."0=" .$ClassID;
	$rsc=$mydb->db_query($sqlrs);
	$num=$mydb->db_num_rows($rsc);
	$MenuRs=$mydb->db_fetch_array($rsc);
	if($num>0)
	{
		$urlq="MenuId=".$_REQUEST["MenuId"]."&";
		return "<a href='?".$urlq.$SystemTablename[0]."_".$dnum."_id=".$ClassID."'>".$MenuRs[0]."</a>";
	}
	else
	{
		return "";
	}
}
	
//获取大类ID

function GetMaxClassID($mydb,$ClassID)
{
	if($ClassID=="") return -1;
	global $SystemTablename;
	global $SystemConest;
	$ClassID=getkuohaostr($ClassID,"/([\d]+)/");
	$sqlrs="Select ".$SystemTablename[0]."2 From ".$SystemConest[7].$SystemTablename[0]." Where ".$SystemTablename[0]."0=" .$ClassID;
	
	$rsc=$mydb->db_query($sqlrs);
	$num=$mydb->db_num_rows($rsc);
	$MenuRs=$mydb->db_fetch_array($rsc);
	if($num>0)
	{
		if($MenuRs[0]==0)
		{
			return $ClassID;
		}
		else
		{
			return $MenuRs[0];
		}
	}
	else
	{
		return -1;
	}
}
?>
